<?
/**
 * GDataGridActionOption
 */
class GDataGridActionOption{
	public $link=NULL;
	public function __construct(GDataGridLink $link=NULL){
		$this->setLink($link);
	}

	public function getLink(){
		return($this->link);
	}
	public function setLink($link){
		$this->link=$link;
	}

	public function toHtml($row){
		$result=false;
		$tmp=$this->getLink();
		$link=new GDataGridLink($tmp->getInnerHtml(),$tmp->getHref(),$tmp->getTarget(),$tmp->getClass(),$tmp->getId(),$tmp->getExtra());
		if($link&&$link!==NULL){
			$href=$link->getHref();
			if(preg_match_all('/##([^#]+)##/',$href,$matches)){
				$matches=$matches[1];
				for($c=0;$c<count($matches);$c++){
					$match=$matches[$c];
					$replace="";
					if($match=="id"){
						$replace=model::numencrypt($row["id"],$row["dateAdded"]);
					}else{
						$replace=$row[$match];
					}
					$href=preg_replace("/##$match##/",$replace,$href);
				}
				$link->setHref($href);
			}
			$result=$link->toHtml();
		}
		return($result);
	}
};
?>
